/**
 * Classname :AccountAJAXAction.java
 *
 * Version information: 1.0
 *
 * Date: Dec 27, 2010 ho.viet.duan create
 *
 * Planex Viet Name co.ltd, All Rights Reserved.
 */

package com.zho.web.action.account;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.zho.business.AccountManager;
import com.zho.domain.model.CustomerInfo;
import com.zho.util.Logit;
import com.zho.web.common.context.Utilities;
import com.zho.web.domain.model.AccountAjaxModel;

/**
 *
 * @author Ho.Viet.Duan	
 * Created Dec 06, 2011
 */
public class AccountAJAXAction extends ActionSupport implements ModelDriven<AccountAjaxModel> {

	private static final long serialVersionUID = 1L;

	private Logit log = Logit.getInstance(AccountAJAXAction.class);
	AccountAjaxModel model = new AccountAjaxModel();
	AccountManager accountManager = null;

	public void setAccountManager(AccountManager accountManager) {
		this.accountManager = accountManager;
	}
	
	public AccountAjaxModel getModel() {
		return model;
	}

	/**
	 * Update part1
	 */
	public String executeUpdateProfile() throws Exception {
		try {
				
		} catch (Exception e) {
			// TODO: handle exception
			log.error(e.getMessage(), e);
			throw e;
		}
		System.out.println("SUCCESS");
		return SUCCESS;
	}
	
	/**
	 * Update password
	 */
	public String executeUpdatePassword() throws Exception {
		try {
			CustomerInfo customerInfo = model.getCustomerInfo();
			System.out.println("customerInfo.getUpdateType() = " + customerInfo.getUpdateType());

				customerInfo.setCustomerId(Utilities.getCurrentLoginUserId());
				accountManager.updateCustomer(customerInfo, customerInfo.getUpdateType());
				model.setSuccessMessage(getText("message.customer.update.profile.success"));
			
		} catch (Exception e) {
			// TODO: handle exception
			log.error(e.getMessage(), e);
			throw e;
		}
		return SUCCESS;
	}

}